<?php
// +-----------------------+
// | 注释不留名，代码随便用 |
// +-----------------------+

namespace addons\taglib;

use think\template\TagLib;

class Preload extends TagLib
{
    // 标签定义
    protected $tags = [
        // 标签定义： attr 属性列表 close 是否闭合（0 或者1 默认1） alias 标签别名 level 嵌套层次
        'css' => ['attr' => '', 'close' => 0],
        'js' => ['attr' => '', 'close' => 0],
    ];

    public function tagCss($tag)
    {
        $parseStr = '';
        $addonsCss = config('addons.pre_load.css');
        if(!empty($addonsCss))
        {
            foreach($addonsCss as $css){
                $parseStr .='<link rel="stylesheet" href="' .$css . '" />';
            }
        }
        return $parseStr;
    }

    public function tagJs($tag){
        $addonsJs = config('addons.pre_load.js');
        $parseStr = '';
        if(!empty($addonsJs))
        {
            foreach($addonsJs as $src){
                $parseStr .='<script  src="' .$src . '"></script>';
            }
        }
        return $parseStr;
    }
}